package ihm;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;


public class FenetreMenu extends JFrame implements ActionListener
{

	private JPanel contentPane;
	private JMenuBar menuBar;
	private JMenu mnFichier;
	private JMenu mnDonneesMetiers;
	private JMenu mnArticles;
	private JMenuItem mniAjouter;
	private JMenuItem mniModifier;
	private JMenuItem btnQuitter;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				try
				{
					FenetreMenu frame = new FenetreMenu();
					frame.setVisible(true);
				} catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public FenetreMenu()
	{
		setTitle("Fenetre Menu");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		
		menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		mnFichier = new JMenu("Fichier");
		menuBar.add(mnFichier);
		
		btnQuitter = new JMenuItem("Quitter");
		btnQuitter.addActionListener(this);
		mnFichier.add(btnQuitter);
		
		mnDonneesMetiers = new JMenu("Donn\u00E9es m\u00E9tiers");
		menuBar.add(mnDonneesMetiers);
		
		mnArticles = new JMenu("Articles");
		mnDonneesMetiers.add(mnArticles);
		
		mniAjouter = new JMenuItem("Ajouter");
		mniAjouter.addActionListener(this);
		mnArticles.add(mniAjouter);
		
		mniModifier = new JMenuItem("Modifier");
		mnArticles.add(mniModifier);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
	}
	public void actionPerformed(ActionEvent e) 
	{
		if (e.getSource() == this.btnQuitter)
		{
			System.exit(0);
		}
		if (e.getSource() == this.mniAjouter)
		{
			JInternalFrame f;
			f = new FenetreAjoutArticle();
			//f = FenetreAjoutArticle;
			
    		f.setBounds(20,20,500,400);
    		f.setTitle("Ajout d'un article");
    		//f.setModal(true);
    		f.setLocation(100,100);
    		f.setVisible(true);
		}
	}
}
